import 'package:data/repository/projects/projects_repository.dart';
import 'package:domain/mapper/projects_domain_model_mapper.dart';
import 'package:domain/model/projects_domain_model.dart';

abstract class ProjectsUseCase {
  Future<ProjectsDomainModel> fetchProjects({int page = 1, int chapterId = 0});
}

class ProjectsUseCaseImpl implements ProjectsUseCase {
  final ProjectsRepository _repository;

  const ProjectsUseCaseImpl({required ProjectsRepository repository})
    : _repository = repository;

  @override
  Future<ProjectsDomainModel> fetchProjects({
    int page = 1,
    int chapterId = 0,
  }) async {
    final response = await _repository.fetchProjects(
      pageIndex: page,
      categoryId: chapterId,
    );
    return response.toDomainModel();
  }
}
